package com.hmall.web;


import com.hmall.common.PageDTO;
import com.hmall.search.ItemDoc;

import com.hmall.search.RequestParams;
import com.hmall.service.ISearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("search")
public class SearchController {

    @Autowired(required = false)
    private ISearchService iSearchService;

    @GetMapping("/suggestion")
    public List<String> suggestion(String key){
        return iSearchService.suggestion(key);
    }

    @PostMapping("/filters")
    public Map<String,List<String>> filters(@RequestBody RequestParams requestParams){
        return iSearchService.filters(requestParams);
    }

    @PostMapping("/list")
    public PageDTO<ItemDoc> list(@RequestBody RequestParams requestParams){
        PageDTO<ItemDoc> pageDTO = iSearchService.list(requestParams);
        return pageDTO;
    }
}
